home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / rprint_1 / gridinpu.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-05-30  |  12.5 KB  |  412 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form Formiga 
  4.    BackColor       =   &H00FFFFFF&
  5.    Caption         =   "Grid "
  6.    ClientHeight    =   8460
  7.    ClientLeft      =   -105
  8.    ClientTop       =   2355
  9.    ClientWidth     =   11205
  10.    LinkTopic       =   "Form1"
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   8460
  13.    ScaleWidth      =   11205
  14.    WindowState     =   2  'Maximized
  15.    Begin VB.Frame Frame2 
  16.       BackColor       =   &H00FFFFFF&
  17.       BorderStyle     =   0  'None
  18.       Height          =   2295
  19.       Left            =   165
  20.       TabIndex        =   3
  21.       Top             =   -150
  22.       Width           =   9855
  23.       Begin VB.TextBox Invoice 
  24.          Appearance      =   0  'Flat
  25.          Height          =   285
  26.          Left            =   6090
  27.          TabIndex        =   11
  28.          Text            =   "Invoice"
  29.          Top             =   720
  30.          Width           =   1215
  31.       End
  32.       Begin VB.TextBox Country 
  33.          Appearance      =   0  'Flat
  34.          Height          =   375
  35.          Left            =   6120
  36.          TabIndex        =   9
  37.          Text            =   "Country"
  38.          Top             =   1680
  39.          Width           =   2775
  40.       End
  41.       Begin VB.TextBox CustAddress 
  42.          Appearance      =   0  'Flat
  43.          Height          =   375
  44.          Left            =   6090
  45.          TabIndex        =   8
  46.          Text            =   "CustAddress"
  47.          Top             =   1080
  48.          Width           =   2775
  49.       End
  50.       Begin VB.TextBox Date 
  51.          Appearance      =   0  'Flat
  52.          Height          =   375
  53.          Left            =   6090
  54.          TabIndex        =   7
  55.          Text            =   "Date"
  56.          Top             =   300
  57.          Width           =   1935
  58.       End
  59.       Begin VB.TextBox City 
  60.          Appearance      =   0  'Flat
  61.          Height          =   375
  62.          Left            =   3480
  63.          TabIndex        =   6
  64.          Text            =   "City"
  65.          Top             =   1680
  66.          Width           =   2580
  67.       End
  68.       Begin VB.TextBox CustomerName 
  69.          Appearance      =   0  'Flat
  70.          Height          =   405
  71.          Left            =   3480
  72.          TabIndex        =   4
  73.          Text            =   "CustomerName"
  74.          Top             =   1080
  75.          Width           =   2565
  76.       End
  77.       Begin VB.Label Label3 
  78.          Alignment       =   2  'Center
  79.          BackStyle       =   0  'Transparent
  80.          Caption         =   "MsFlexGrid Cell Edit Example"
  81.          BeginProperty Font 
  82.             Name            =   "MS Sans Serif"
  83.             Size            =   9.75
  84.             Charset         =   177
  85.             Weight          =   700
  86.             Underline       =   0   'False
  87.             Italic          =   0   'False
  88.             Strikethrough   =   0   'False
  89.          EndProperty
  90.          ForeColor       =   &H00C00000&
  91.          Height          =   375
  92.          Left            =   15
  93.          TabIndex        =   12
  94.          Tag             =   "noprint"
  95.          Top             =   1800
  96.          Width           =   3375
  97.       End
  98.       Begin VB.Image Image1 
  99.          Height          =   1335
  100.          Left            =   -15
  101.          Picture         =   "GridInput.frx":0000
  102.          Stretch         =   -1  'True
  103.          Top             =   135
  104.          Width           =   3000
  105.       End
  106.       Begin VB.Label Label2 
  107.          BackStyle       =   0  'Transparent
  108.          Caption         =   "Order"
  109.          Height          =   255
  110.          Left            =   5340
  111.          TabIndex        =   10
  112.          Top             =   720
  113.          Width           =   615
  114.       End
  115.       Begin VB.Label Label1 
  116.          BackStyle       =   0  'Transparent
  117.          Caption         =   "Bill To"
  118.          Height          =   255
  119.          Left            =   3360
  120.          TabIndex        =   5
  121.          Top             =   720
  122.          Width           =   615
  123.       End
  124.    End
  125.    Begin VB.Frame Frame1 
  126.       BackColor       =   &H00FFFFFF&
  127.       BorderStyle     =   0  'None
  128.       Height          =   6255
  129.       Left            =   225
  130.       TabIndex        =   0
  131.       Top             =   2175
  132.       Width           =   9975
  133.       Begin VB.PictureBox inputpic 
  134.          Appearance      =   0  'Flat
  135.          BackColor       =   &H00FFFFFF&
  136.          ForeColor       =   &H80000008&
  137.          Height          =   300
  138.          Left            =   1080
  139.          ScaleHeight     =   270
  140.          ScaleWidth      =   795
  141.          TabIndex        =   1
  142.          Tag             =   "noprint"
  143.          Top             =   720
  144.          Visible         =   0   'False
  145.          Width           =   825
  146.          Begin VB.TextBox TMText 
  147.             Appearance      =   0  'Flat
  148.             BorderStyle     =   0  'None
  149.             BeginProperty Font 
  150.                Name            =   "MS Sans Serif"
  151.                Size            =   9.75
  152.                Charset         =   177
  153.                Weight          =   400
  154.                Underline       =   0   'False
  155.                Italic          =   0   'False
  156.                Strikethrough   =   0   'False
  157.             EndProperty
  158.             Height          =   390
  159.             Left            =   15
  160.             TabIndex        =   2
  161.             ToolTipText     =   "Enter data"
  162.             Top             =   0
  163.             Width           =   840
  164.          End
  165.       End
  166.       Begin MSFlexGridLib.MSFlexGrid gridinv 
  167.          Height          =   4965
  168.          Left            =   90
  169.          TabIndex        =   15
  170.          Top             =   180
  171.          Width           =   10530
  172.          _ExtentX        =   18574
  173.          _ExtentY        =   8758
  174.          _Version        =   393216
  175.          Rows            =   25
  176.          Cols            =   5
  177.          FixedCols       =   0
  178.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  179.             Name            =   "MS Sans Serif"
  180.             Size            =   9.75
  181.             Charset         =   177
  182.             Weight          =   400
  183.             Underline       =   0   'False
  184.             Italic          =   0   'False
  185.             Strikethrough   =   0   'False
  186.          EndProperty
  187.       End
  188.       Begin VB.Label Total 
  189.          Appearance      =   0  'Flat
  190.          BackColor       =   &H80000005&
  191.          BackStyle       =   0  'Transparent
  192.          BorderStyle     =   1  'Fixed Single
  193.          Caption         =   "Total"
  194.          ForeColor       =   &H80000008&
  195.          Height          =   255
  196.          Left            =   7290
  197.          TabIndex        =   14
  198.          Top             =   5490
  199.          Width           =   615
  200.       End
  201.       Begin VB.Label TotalInv 
  202.          Alignment       =   1  'Right Justify
  203.          BackStyle       =   0  'Transparent
  204.          Height          =   255
  205.          Left            =   8025
  206.          TabIndex        =   13
  207.          Top             =   5505
  208.          Width           =   1110
  209.       End
  210.    End
  211. Attribute VB_Name = "Formiga"
  212. Attribute VB_GlobalNameSpace = False
  213. Attribute VB_Creatable = False
  214. Attribute VB_PredeclaredId = True
  215. Attribute VB_Exposed = False
  216. Dim LastLine As Integer
  217. Dim Edit As Boolean
  218. Dim OldCol As Integer
  219. Dim OldRow As Integer
  220. Private Sub Form_Activate()
  221. gridinv.Col = 0
  222. TMText.SetFocus
  223. End Sub
  224. Private Sub Form_Load()
  225. LastLine = 25
  226. Setgrid
  227. gridinv.Col = 1
  228. End Sub
  229. Private Sub gridinv_EnterCell()
  230. Dim ResNo As Integer
  231. On Error Resume Next
  232. If Init Then Exit Sub
  233. ResNo = 116
  234. If gridinv.Col = 4 Then
  235. gridinv.Col = OldCol
  236. Exit Sub
  237. End If
  238. inputpic.Move gridinv.CellLeft - 20
  239. inputpic.Top = gridinv.CellTop + gridinv.Top - 20
  240. inputpic.Visible = True
  241. inputpic.Width = gridinv.CellWidth + 10
  242. inputpic.Height = gridinv.CellHeight + 20
  243. TMText.Width = inputpic.Width
  244. OldCol = gridinv.Col
  245. OldRow = gridinv.Row
  246. TMText.SetFocus
  247. TMText.Text = gridinv.Text
  248. TMText.SelStart = 0
  249. TMText.SelLength = 100
  250. OldCol = gridinv.Col
  251. OldRow = gridinv.Row
  252. TMText.SetFocus
  253. End Sub
  254. Private Sub GridInv_KeyDown(KeyCode As Integer, Shift As Integer)
  255. Dim reik
  256. reik = ""
  257. Select Case KeyCode
  258. Case KEY_HOME
  259. gridinv.Row = 1
  260. KeyCode = 0
  261. If Not gridinv.RowIsVisible(1) Then gridinv.TopRow = 1
  262. Case KEY_END
  263. KeyCode = 0
  264. gridinv.Row = LastLine
  265. If Not gridinv.RowIsVisible(LastLine) Then gridinv.TopRow = LastLine - 3
  266. Case KEY_HOME
  267. gridinv.Row = 1:
  268. KeyCode = 0
  269. If Not gridinv.RowIsVisible(1) Then gridinv.TopRow = 1
  270. End Select
  271. If KeyCode = 46 Then
  272. If Not Edit Then
  273. gridinv.Text = ""
  274. Exit Sub
  275. End If
  276. End If
  277. Newline = 0
  278. KeyCode = 0
  279. End Sub
  280. Private Sub gridinv_LeaveCell()
  281. Dim The_Col As Integer, the_Row As Integer
  282. Dim Tot As Double
  283. If gridinv.Col = 4 Then Exit Sub
  284. The_Col = gridinv.Col
  285. the_Row = gridinv.Row
  286. gridinv.Text = TMText.Text
  287. If Edit And (The_Col = 2 Or The_Col = 3) And (Not IsNumeric(gridinv.Text)) Then gridinv.Text = "0"
  288. If Edit And (The_Col = 2 Or The_Col = 3) And (IsNumeric(gridinv.TextMatrix(the_Row, 2)) _
  289. And IsNumeric(gridinv.TextMatrix(the_Row, 3))) Then
  290. Tot = CDbl(gridinv.TextMatrix(the_Row, 2)) * CDbl(gridinv.TextMatrix(the_Row, 3))
  291. gridinv.TextMatrix(the_Row, 4) = Str$(Tot)
  292. TotalSum
  293. End If
  294. Edit = False
  295. End Sub
  296. Private Sub gridinv_Scroll()
  297. If Not gridinv.RowIsVisible(gridinv.Row) Or Not gridinv.ColIsVisible(gridinv.Col) Then
  298. inputpic.Visible = False
  299. inputpic.Move gridinv.CellLeft
  300. inputpic.Top = gridinv.CellTop + gridinv.Top
  301. inputpic.Visible = True
  302. End If
  303. End Sub
  304. Private Sub TMtext_KeyDown(KeyCode As Integer, Shift As Integer)
  305. Select Case KeyCode
  306. Case 27
  307. TMText = gridinv.Text
  308. Case 40
  309. If gridinv.Row < LastLine - 1 Then gridinv.Row = gridinv.Row + 1
  310. Case 38
  311. If gridinv.Row > 1 Then gridinv.Row = gridinv.Row - 1
  312. KeyCode = 0
  313. Case KEY_END
  314. KeyCode = 0
  315. gridinv.Row = LastLine
  316. If Not gridinv.RowIsVisible(LastLine) Then gridinv.TopRow = LastLine - 3
  317. Case KEY_HOME
  318. gridinv.Row = 1:
  319. KeyCode = 0
  320. If Not gridinv.RowIsVisible(1) Then gridinv.TopRow = 1
  321. End Select
  322. If KeyCode = 46 Then
  323. If Not Edit Then
  324. gridinv.Text = ""
  325. Exit Sub
  326. End If
  327. End If
  328. End Sub
  329. Private Sub TMtext_KeyPress(KeyAscii As Integer)
  330. If KeyAscii = 13 Then
  331. If gridinv.Col < 3 Then
  332. gridinv.Col = gridinv.Col + 1
  333. If gridinv.Row < LastLine Then gridinv.Col = 0: gridinv.Row = gridinv.Row + 1
  334. End If
  335. Edit = True
  336. End If
  337. End Sub
  338. Private Sub Setgrid()
  339. Dim Dollars As Currency
  340. Dim Qntys As Double
  341. gridinv.Move 0, 300
  342. inputpic.Visible = True
  343. gridinv.ColWidth(1) = 3600
  344. gridinv.ColWidth(2) = 1500
  345. gridinv.ColWidth(3) = 1500
  346. gridinv.ColWidth(4) = 1500
  347. gridinv.TextMatrix(0, 0) = "Item Code"
  348. gridinv.TextMatrix(0, 1) = "Item Name"
  349. gridinv.TextMatrix(0, 2) = "Quantity"
  350. gridinv.TextMatrix(0, 3) = "Price"
  351. gridinv.TextMatrix(0, 4) = "SubTotal"
  352. gridinv.TextMatrix(1, 0) = "0007845"
  353. gridinv.TextMatrix(1, 1) = "Giraffe"
  354. gridinv.ColAlignment(3) = 8
  355. gridinv.ColAlignment(4) = 8
  356. gridinv.TextMatrix(1, 2) = "35"
  357. Dollars = 118.95
  358. gridinv.TextMatrix(1, 3) = Str$(Dollars)
  359. Dollars = 4163.25
  360. gridinv.TextMatrix(1, 4) = Str$(Dollars)
  361. gridinv.TextMatrix(2, 0) = "0006984"
  362. gridinv.TextMatrix(2, 1) = "Lion"
  363. gridinv.TextMatrix(2, 2) = "7"
  364. Dollars = 99.99
  365. gridinv.TextMatrix(2, 3) = Str$(Dollars)
  366. Dollars = 349.93
  367. gridinv.TextMatrix(2, 4) = Str$(Dollars)
  368. gridinv.TextMatrix(3, 0) = "0000183"
  369. gridinv.TextMatrix(3, 1) = "Snake"
  370. gridinv.TextMatrix(3, 2) = "1"
  371. Dollars = 96.99
  372. gridinv.TextMatrix(3, 3) = Str$(Dollars) '"$96.99"
  373. gridinv.TextMatrix(3, 4) = Str$(Dollars) ' "$96.99"
  374. gridinv.TextMatrix(4, 0) = "0003155"
  375. gridinv.TextMatrix(4, 1) = "Hippopotami"
  376. gridinv.TextMatrix(4, 2) = "10"
  377. Dollars = 214.99
  378. gridinv.TextMatrix(4, 3) = Str$(Dollars)
  379. gridinv.TextMatrix(4, 4) = Str$(Dollars * 10)
  380. gridinv.TextMatrix(5, 0) = "0007825"
  381. gridinv.TextMatrix(5, 1) = "Crocodile"
  382. gridinv.TextMatrix(5, 2) = "6"
  383. Dollars = 235.99
  384. gridinv.TextMatrix(5, 3) = Str$(Dollars)
  385. gridinv.TextMatrix(5, 4) = Str$(Dollars * 6)
  386. gridinv.Col = 0
  387. LastLine = 6
  388. gridinv_EnterCell
  389. Date = Format(Now, "dd/mm/yy")
  390. Invoice = "1000345"
  391. CustomerName = "Santa Claus"
  392. CustAddress = "Sky st 1"
  393. City = "Los Angeles"
  394. Country = "Holyland"
  395. TotalSum
  396. TMText.SelStart = 0
  397. TMText.SelLength = 100
  398. End Sub
  399. Private Sub TotalSum()
  400. Dim i As Integer
  401. Dim Sum As Double
  402. Dim IsEmpty As Boolean
  403. i = 1
  404. Do While Not IsEmpty
  405. If gridinv.TextMatrix(i, 4) = "" Then
  406. IsEmpty = True
  407. Sum = Sum + CDbl(gridinv.TextMatrix(i, 4))
  408. i = i + 1
  409. End If
  410. TotalInv = Str$(Sum)
  411. End Sub
  412.